import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn, ManyToOne, JoinColumn } from 'typeorm';
import { User } from '../../user/user.entity';
import { CustomerServiceAgent } from './agent.entity';
import { CustomerServiceGroup } from './group.entity';

@Entity('customer_service_session')
export class CustomerServiceSession {
  @PrimaryGeneratedColumn()
  id: number;

  @ManyToOne(() => User)
  @JoinColumn({ name: 'userId' })
  user: User;

  @ManyToOne(() => CustomerServiceAgent, { nullable: true })
  @JoinColumn({ name: 'agentId' })
  agent: CustomerServiceAgent;

  @ManyToOne(() => CustomerServiceGroup, { nullable: true })
  @JoinColumn({ name: 'groupId' })
  group: CustomerServiceGroup;

  @Column({ default: 'open' })
  status: 'open' | 'closed' | 'pending' | 'transferred';

  @Column({ nullable: true })
  closedReason: string;

  @Column({ nullable: true })
  transferredToAgentId: number;

  @Column({ nullable: true })
  rating: number;

  @Column({ nullable: true })
  ratingComment: string;

  @CreateDateColumn()
  createdAt: Date;

  @UpdateDateColumn()
  updatedAt: Date;
} 